FROM php:8.1.0RC5-fpm-buster
COPY php-fpm.conf /usr/local/etc/php-fpm.conf
COPY www.conf /usr/local/etc/php-fpm.d/www.conf
COPY php.ini /usr/local/etc/php/php.ini

ENV PHPIZE_DEPS \
        autoconf \
        dpkg-dev \
        file \
        g++ \
        gcc \
        libc-dev \
        make \
        pkg-config \
        re2c

# persistent / runtime deps
RUN set -eux; \
    apt-get update; \
    apt-get install -y --no-install-recommends \
        $PHPIZE_DEPS \
        ca-certificates \
        curl \
        xz-utils \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libpng-dev \
    ; \
rm -rf /var/lib/apt/lists/*

RUN pecl channel-update pecl.php.net
RUN pecl install redis \
    && docker-php-ext-enable redis
#    && pecl install xdebug

RUN pecl install xdebug
#    && docker-php-ext-enable xdebug
RUN docker-php-ext-install gd \
#    && docker-php-ext-install mbstring \
    && docker-php-ext-install mysqli \
    && docker-php-ext-install pdo \
    && docker-php-ext-install pdo_mysql \
    && docker-php-ext-install sockets

RUN docker-php-ext-enable gd \
#    && docker-php-ext-enable mbstring \
    && docker-php-ext-enable mysqli \
    && docker-php-ext-enable pdo \
    && docker-php-ext-enable pdo_mysql \
    && docker-php-ext-enable sockets

# 安装扩展
# RUN pecl install redis \
#    && docker-php-ext-enable redis \
# RUN pecl install pdo_mysql \
#    && docker-php-ext-enable pdo_mysql

# RUN apt-get update && apt-get install -y \
#        libfreetype6-dev \
#        libjpeg62-turbo-dev \
#        libpng-dev \
#    && docker-php-ext-install -j$(nproc) iconv \
#    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
#    && docker-php-ext-install -j$(nproc) gd

# RUN apt-get update && apt-get install -y \
#        libfreetype6-dev \
#        libjpeg62-turbo-dev \
#        libpng-dev \
#    && docker-php-ext-install -j$(nproc) iconv \
#    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
#    && docker-php-ext-install -j$(nproc) gd

# 安装其他扩展
# RUN curl -fsSL 'https://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.gz' -o xcache.tar.gz \
#    && mkdir -p xcache \
#    && tar -xf xcache.tar.gz -C xcache --strip-components=1 \
#    && rm xcache.tar.gz \
#    && ( \
#        cd xcache \
#        && phpize \
#        && ./configure --enable-xcache \
#        && make -j "$(nproc)" \
#        && make install \
#    ) \
#    && rm -r xcache \
#    && docker-php-ext-enable xcache

# Use the default production configuration
# RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

# Override with custom opcache settings
# COPY config/opcache.ini $PHP_INI_DIR/conf.d/

